package com.ithong.drug.service.impl;

import ch.qos.logback.core.joran.action.ActionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ithong.drug.entity.DrugInfo;
import com.ithong.drug.entity.Owinfo;
import com.ithong.drug.mapper.OwInfoMapper;
import com.ithong.drug.service.OwInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;

import java.util.List;

@Service
public class OwInfoServiceImpl extends ServiceImpl<OwInfoMapper, Owinfo> implements OwInfoService {

    @Autowired
    private OwInfoMapper owInfoMapper;

    @Override
    public IPage<Owinfo> selectowinfoPage(int pageNum, int pageSize, String param) {
        QueryWrapper<Owinfo> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(param)){
            wrapper.like("dname",param);
        }
        Page<Owinfo> page = new Page<>(pageNum,pageSize);
        return owInfoMapper.selectPage(page,wrapper);
    }

    @Override
    public int addowinfo(Owinfo owinfo) {
        return owInfoMapper.insert(owinfo);
    }

    @Override
    public int editowinfo(Owinfo owinfo) {
        return owInfoMapper.updateById(owinfo);
    }

    @Override
    public Owinfo queryowinfoById(Integer id) {
        return owInfoMapper.selectById(id);
    }

    @Override
    public int delowinfo(Integer id) {
        return owInfoMapper.deleteById(id);
    }

    @Override
    public List<Owinfo> queryowinfoList() {
        return owInfoMapper.selectList(null);
    }
}
